package com.wimcorp.magic.data;

import java.io.Serializable;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

@Entity
@Table(name = "abilitydata", schema = "carddata")
public class AbilityData implements Serializable {

	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE)
	private Long id;
	private String ability;
	@Column(columnDefinition = "text")
	private String config;

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
	@JoinTable(name = "abilitydata_costdata", schema = "carddata", joinColumns = @JoinColumn(name = "abilitydata_id", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "cost_id", referencedColumnName = "id"))
	private Set<CostData> costs = new HashSet<>();

	public AbilityData() {

	}

	public AbilityData(String ability, String config, Set<CostData> costs) {
		this.ability = ability;
		this.config = config;
		this.costs = new HashSet<>(costs);
	}

	public String getAbility() {
		return ability;
	}

	public void setAbility(String ability) {
		this.ability = ability;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String toString() {

		return "{id : " + id + ",ability : " + ability + ",config : " + config + "}";
	}

	public String getConfig() {
		return config;
	}

	public void setConfig(String config) {
		this.config = config;
	}

	public Set<CostData> getCosts() {
		return costs;
	}

	public void setCosts(Set<CostData> costs) {
		this.costs=costs;
		
	}
	
	

}
